/*
 * Copyright Thoughtworks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@use "sass:color";
@use "sass:map";
@import "../../global/common";

$spinner-wrapper-height: 100px;
$selected-table-row: #e2f7fa;

.hidden {
  display: none;
}

.filter-by-heading {
  width: 60%;
}

.plugin-role {
  @include icon-before($type: $fa-var-circle, $color: $warning-txt);
}

.gocd-role {
  display: inline-block;

  @include icon-before($type: $fa-var-circle, $color: $go-primary);
}

.user-management-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  position: fixed;
  left: 30px;
  right: 30px;
  background: $body-bg;
  top: 90px;
  padding: 15px 0;
  z-index: map.get($zindex, user-management-header);
}

.user-actions-and-counts {
  display: flex;
  justify-content: flex-start;
}

.user-actions {
  display: flex;
  margin-right: 20px;
}

.user-filters {
  display: flex;
}

.filter-dropdown {
  position: relative;
  margin-left: 5px;
}

@mixin dropdown-content() {
  background: $white;
  position: absolute;
  border-radius: $global-border-radius;
  padding: 20px;
  box-shadow: 0 2px 4px $box-shadow-color;
}

.filter-dropdown-content {
  @include dropdown-content;

  z-index: map.get($zindex, "users-management-filter");
  top: 36px;
  right: 0;
  width: 570px;
}

.roles-dropdown-content {
  @include dropdown-content;

  width: 250px;
  right: 0;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  padding: 0 20px 10px 20px;
  margin: 0 -20px;
  border-bottom: 1px solid $border-color;

  h4 {
    margin: 0;
  }
}

.filters-body {
  display: flex;
}

.filter-items {
  width: 33.3%;
  padding: 15px 0;
}

.filter-items-head {
  margin: 0 0 20px 0;
}

.roles-list {
  max-height: 250px;
  overflow: auto;
  margin-bottom: 10px;
}

.filter-by-roles {
  max-height: 250px;
  overflow: scroll;
}

.role-legends {
  display: inline-flex;
  background: $white;
  flex-wrap: nowrap;
  padding: 0 5px 0 0;
  border-radius: 3px;
  margin-left: 10px;
  text-transform: none;
}

.role-gocd {
  font-size: 12px;

  @include icon-before($type: $fa-var-circle, $color: $go-primary);
}

.role-plugin {
  font-size: 12px;

  @include icon-before($type: $fa-var-circle, $color: $warning-txt);
}

.search-user {
  margin-bottom: 20px;

  .button {
    margin-left: 5px;
  }
}

.disabled {
  color: $go-disabled;
  font-style: italic;
}

.spinner-wrapper {
  min-height: $spinner-wrapper-height;
}

.admin-switch-wrapper {
  display: flex;
  align-items: center;
}

.is-admin-text {
  margin: 0 10px 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.flex-table {
  border-radius: $global-border-radius $global-border-radius 0 0;
}

.table-header {
  background: $secondary-bg;
  border-radius: $global-border-radius $global-border-radius 0 0;
  position: static;
  left: 30px;
  right: 30px;
  display: flex;
  align-items: center;
  flex-grow: 1;
  box-sizing: border-box;
  font-weight: 600;
  top: 155px;
  z-index: map.get($zindex, user-management-table-header);

  .has-message & {
    margin-top: 44px;
  }
}

.table-head {
  text-transform: uppercase;
  text-align: left;
  font-weight: 600;
}

.table-row {
  border-bottom: 1px solid $border-color;
  min-height: 45px;
  display: flex;
  align-items: center;
  width: 100%;
  flex-grow: 1;
  box-sizing: border-box;
  font-weight: 600;
  background: $white;

  &.selected {
    background: $selected-table-row;
  }
}

.table-body {
  height: calc(100vh - 321px);
  overflow-y: auto;

  .has-message & {
    height: calc(100vh - 420px);
    padding-top: 40px;
    overflow: auto;
  }
}

.table-head,
.table-cell {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  padding: 10px;

  &:nth-child(1) {
    width: 3%;
    justify-content: center;
  }

  &:nth-child(2) {
    width: 20%;
    word-break: break-all;
  }

  &:nth-child(3) {
    width: 20%;
    word-break: break-all;
  }

  &:nth-child(4) {
    width: 21%;
  }

  &:nth-child(5) {
    width: 12%;
  }

  &:nth-child(6) {
    width: 18%;
    word-break: break-all;
  }

  &:nth-child(7) {
    width: 6%;
  }
}

.fl-error {
  color: $go-danger;
  padding: 10px;
  border-top: 1px solid $go-danger;

  p {
    margin: 0;
  }
}

.form-check {
  height: 16px;
  width: 16px;
}

.system-admin-cell {
  display: flex;
}

.icon-check {
  @include icon-before($type: $fa-var-check, $color: $go-green);

  &::before {
    margin: 0 5px;
  }
}

.icon-error {
  @include icon-before($type: $fa-var-exclamation-circle, $color: $go-danger);
}

.alert-error {
  width: 100%;
  font-weight: 600;
  font-size: 12px;
  padding: 7px 40px 7px 25px;
  border: 1px solid transparent;
  position: relative;
  background-color: $alert;
  color: color.adjust($alert, $lightness: -50%);
  border-color: color.adjust($alert, $lightness: -10%);

  p {
    margin: 0;
  }
}

.to-be-deleted-users {
  font-weight: 600;
  margin-top: 10px;
  display: block;
}

.flash-message-wrapper-container {
  margin-top: 45px;

  &.has-message {
    position: fixed;
    top: 110px;
    left: 30px;
    right: 30px;
  }
}
